package hospital.controller;

import hospital.model.hosp.Hospital;
import hospital.result.Result;
import hospital.service.HospitalService;
import hospital.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author
 * @description:
 */
@RestController
@RequestMapping("/admin/hosp/hospital")
//@CrossOrigin //跨域注解
@Api(tags = "医院列表")
public class HospitalController {
    @Autowired
    private HospitalService hospitalService;

    /**
     * @Author yang
     * @Description //TODO 得到医院的列表
     * @Param [page, limit, vo]
     * @return
     **/
    @PostMapping("list/{page}/{limit}")
    public Result listHospital(@PathVariable Integer page,
                               @PathVariable Integer limit,
                               @RequestBody(required= false) HospitalQueryVo vo){
        //得到医院的列表
        Page<Hospital> hospitalPage=hospitalService.getHospitalList(page,limit,vo);
        return Result.ok(hospitalPage);
    }

    /**
     * @Author yang
     * @Description //TODO 更新医院的status,上线或下线
     * @Param
     * @return
     **/
    @ApiOperation("更新医院的上线状态")
    @GetMapping("updateHospitalStatus/{id}/{status}")
    public Result updateHospitalStatus(@PathVariable String id,@PathVariable Integer status){
        hospitalService.updateHospitalStatus(id,status);
        return Result.ok();
    }

    /**
     * @Author yang
     * @Description //TODO 医院详细信息
     * @Param [id]
     * @return
     **/
    @ApiOperation("医院详细信息")
    @GetMapping("showHospitalDetail/{id}")
    public Result showHospitalDetail(@PathVariable String id){
        Map<String,Object> map=hospitalService.showHospitalDetail(id);
        return Result.ok(map);
    }
}
